﻿<!DOCTYPE html>
<!--作业许可证管理=>作业许可证申请=>个人安全防护编辑页 -->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>
<body>
    
<div id="app" v-cloak>   
        <el-table ref="table" :data="ListItem.tableData" :row-key="mygetRowKeys"
                  :height="ListItem.tableHeight"
                  border @selection-change="handleSelectionChange" row-style="height:10px"
                  style="width: 100%">
            <el-table-column type="selection"
                             width="55" :reserve-selection="true"  >
            </el-table-column>
            <el-table-column prop="PersonalSecurityProtectionName"
                             label="个人安全防护"
                             width="180">
            </el-table-column>
            <el-table-column prop="remarks"
                             label="备注" width="240">
            </el-table-column>
        </el-table>
        <el-row type="flex" justify="end">
            <el-pagination ref="page" @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="ListItem.currentPage"
                           :page-sizes="ListItem.pagesizes"
                           :page-size="ListItem.pagesize"
                           :layout="ListItem.layout"
                           :total="ListItem.total">
            </el-pagination>
        </el-row>

        <el-row type="flex" justify="center">
                <el-button type="primary" @click="aaa">{{col.btnConfirm}}</el-button>
        </el-row>

    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data() {
                return {
                    ListItem: ListItem,
                    formInline: {
                        model: { PersonalSecurityProtectionName: '', remarks: '' },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                //初始化数据
                var mythis = this;
                this.GetPageData(1);
                mythis.toggleSelection();
                //列表高度自适应
                tablehigh(this);
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                mygetRowKeys: function (row) {
                    return row.PersonalSecurityProtectionName;
                },
                toggleSelection: function () {
                    var mythis = this;
                    mythis.$nextTick(function () {
                        var rows = parent.app.Form.PersonalSecurityProtection;
                        var array = [];
                        for (var i = 0; i < rows.length; i++) {
                            var obj = {};
                            obj.PersonalSecurityProtectionName = rows[i];
                            array.push(obj);
                        }
                        //array = mythis.$refs.table.data;
                        console.log(this.ListItem.tableMultipleSelection)
                        if (array) {
                            array.forEach(function (arr) {
                                mythis.$refs.table.toggleRowSelection(arr, true);
                            });
                        } else {
                            mythis.$refs.table.clearSelection();
                        }

                    })

                },
                handleNodeClick(data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
              //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/PersonalSecurityProtection/GetList') },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                aaa: function () {
                    console.log(this.ListItem.tableMultipleSelection);
                    parent.app.Form.PersonalSecurityProtection = [];
                    for (var i = 0; i < this.ListItem.tableMultipleSelection.length; i++) {
                        parent.app.Form.PersonalSecurityProtection.push(this.ListItem.tableMultipleSelection[i].PersonalSecurityProtectionName);
                    }
                    parent.app.ListItem.dialogVisible = false;
                }
            }
        });
    </script>
</body>
</html>